package com.bjpowernode.app;
import com.bjpowernode.beans.Stu;
public class MyStuServices {
    //throws MyException向上抛出异常
    public Stu add(String name, float score) throws MyException {
        if (score < 0 || score > 100) {
            //throw关键字触发异常
            throw new MyException("你输入的输入的分数必须是0-100的范围");
            //触发异常之后语句就断了
            //return null;
        }
        if (name.length() > 6 || name.length() <= 0) {
            throw new MyException("你的姓名只能是1-6个字符之间");
        }
        Stu stu = new Stu();
        stu.setName(name);
        stu.setScore(score);
        return stu;
    }
}
